package db_main

import (
	"errors"
	"fmt"
	"gorm.io/gorm"
	"longmen/server/pkg/common/helper/util"
	"longmen/server/pkg/db/mysql"
	"longmen/server/pkg/db/mysql/models/models_main"
)

func GetGoldPricesParam(param map[string]interface{}, order string) ([]*models_main.GoldPrice, error) {
	fName := "GetGoldPricesParam"
	o := make([]*models_main.GoldPrice, 0)
	table := mysql.GetRTable(&models_main.GoldPrice{})
	mysql.Condition(table, param, "", order, 0, 0)
	err := table.Find(&o).Error
	if errors.Is(err, gorm.ErrRecordNotFound) {
		err = nil
	}
	if err != nil {
		err = fmt.Errorf("%s%s", util.Convert(fName), err.Error())
	}
	return o, err
}
